package com.tongyi.controller;

import com.tongyi.service.TongYiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/ai")
@CrossOrigin
public class TongYiController {


    @Autowired
    private TongYiService tongYiSimpleService;

    /**
     * 聊天对话应用  单轮对话
     * @param message
     * @return
     */
    @GetMapping("/example")
    public String completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message, HttpServletRequest request, HttpServletResponse response) {
        String completion = tongYiSimpleService.completion(message);
        return completion;
    }
}
